package com.o2o.cleaning.month.platform.ebusiness_plat.brand_modular.utils

import org.apache.spark.sql.{DataFrame, SparkSession}

/**
  * 这个代码是新增的品牌中没有老字号的数据打上老字号的标签
  * 如果老表中没有老字号的标签打上0
  * 如果老表中没有国家的标签打上-1
  * 如果老表中没有状态的标签打上0
  */
class laozihao_util {

  /**
    * @ describe 老字号处理
    * @return
    */
  def  brand_add_laozihaoaddress (stateResult:DataFrame,spark:SparkSession):DataFrame={

    stateResult.registerTempTable("frames")


    //老字号字段修正
    val datas = spark.sqlContext.sql(
      """
        |select
        |*,
        |case
        |--10021
        |when firstCategoryId = '10021' and brandName rlike '杏花楼' then '1'
        |when firstCategoryId = '10021' and brandName rlike '张裕' then '1'
        |when firstCategoryId = '10021' and brandName rlike '百乐' then '1'
        |when firstCategoryId = '10021' and brandName rlike '北京红星二锅头' then '1'
        |when firstCategoryId = '10021' and brandName rlike '红星' then '1'
        |when firstCategoryId = '10021' and brandName rlike '保宁' then '1'
        |when firstCategoryId = '10021' and brandName rlike '国窖' then '1'
        |when firstCategoryId = '10021' and brandName rlike '泸州老酒坊' then '1'
        |when firstCategoryId = '10021' and brandName rlike '五粮头曲' then '1'
        |when firstCategoryId = '10021' and brandName rlike '五粮特曲' then '1'
        |when firstCategoryId = '10021' and brandName rlike '五粮醇' then '1'
        |when firstCategoryId = '10021' and brandName rlike '六和液' then '1'
        |when firstCategoryId = '10021' and brandName rlike '五粮春' then '1'
        |when firstCategoryId = '10021' and brandName rlike '蓝色经典' then '1'
        |when firstCategoryId = '10021' and brandName rlike '梦之蓝'  then '1'
        |when firstCategoryId = '10021' and brandName rlike '万和' then '1'
        |when firstCategoryId = '10021' and brandName rlike '光明' then '1'
        |--10023
        |when firstCategoryId = '10023' and brandName rlike '曹素功' then '1'
        |when firstCategoryId = '10023' and brandName rlike '红星' then '1'
        |--10011
        |when firstCategoryId = '10011' and brandName rlike '三枪' then '1'
        |when firstCategoryId = '10011' and brandName rlike '恒源祥' then '1'
        |--10017
        |when firstCategoryId = '10017' and brandName rlike '华昌' then '1'
        |when firstCategoryId = '10017' and brandName rlike '光明'  then '1'
        |--10022
        |when firstCategoryId = '10022' and brandName rlike '熊猫' then '1'
        |when firstCategoryId = '10022' and brandName rlike '凤凰' then '1'
        |when firstCategoryId = '10022' and brandName rlike '光明' then '1'
        |--10013
        |when firstCategoryId = '10013' and brandName rlike '凤凰' then '1'
        |
        |
        |
        |
        |else brand_isLaoZiHao end lzh
        |
        |from
        |frames
      """.stripMargin)
      .drop("brand_isLaoZiHao")
      .withColumnRenamed("lzh", "brand_isLaoZiHao")



    return datas
  }
}
